import {
    CHANGE_CURRENT_AREA,
    CHANGE_CURRENT_TYPE,
    CHANGE_ARTIST_LIST,
} from './constants';

import { getArtistList } from '@/services/artist';

const changeArtistListAction = (artistList) => ({
    type: CHANGE_ARTIST_LIST,
    artistList
})

export const changeCurrentAreaAction = (area) => ({
    type: CHANGE_CURRENT_AREA,
    currentArea: area
});

export const changeCurrentTypeAction = (type) => ({
    type: CHANGE_CURRENT_TYPE,
    currentType: type
});

export const getArtistListAction = (area, type, alpha) => {
    return dispatch => {
        getArtistList(area, type, alpha).then(res => {
            // console.log(res);
            dispatch(changeArtistListAction(res.artists))
        })
    }
}